package com.atguigu.study.utils;

import java.util.Arrays;
import java.util.Comparator;


public class MethodRefDemoV2
{
    static int cmp0923(String s1, String s2)
    {
        return s1.compareTo(s2);
    }

    public static void main(String[] args)
    {
        String[] array = new String[] { "Apple", "Orange", "Banana", "Lemon" };


        //匿名内部类，new接口
        Arrays.sort(array, new Comparator<String>()
        {
            @Override
            public int compare(String o1, String o2)
            {
                return o1.compareTo(o1);
            }
        });

        //方法引用,替代lambdaExpress
        Arrays.sort(array,MethodRefDemoV2::cmp0923);


        //lambdaExpress
        //Arrays.sort(array, (o1, o2) -> o1.compareTo(o2));


        System.out.println(String.join(", ", array));
    }
}
